﻿using System;
using System.Xml.Serialization;

namespace GACore.Structures
{
	public class FitnessProperties
	{
		public FitnessProperties(FitnessFunctionType fitnessFunctionType, bool minimizeFitnessValue, object objectToCount = null, Vector compareVector = null)
		{
			this.fitnessFunctionType = fitnessFunctionType;
			this.minimizeFitnessValue = minimizeFitnessValue;
			this.objectToCount = objectToCount;
			this.compareVector = compareVector;
			if ((fitnessFunctionType == FitnessFunctionType.EuklidDistance || fitnessFunctionType == FitnessFunctionType.HammingDistance) && compareVector == null)
			{
				throw new ArgumentException("Wenn die Distanz zu einem Vektor gemessen werden soll, muss ein Vergleichsvektor angegeben werden.");
			}
		}

		public FitnessProperties() { }

		private FitnessFunctionType fitnessFunctionType = FitnessFunctionType.Count;
		public FitnessFunctionType FitnessFunctionType
		{
			get { return fitnessFunctionType; }
			set { fitnessFunctionType = value; }
		}

		private bool minimizeFitnessValue;
		public bool MinimizeFitnessValue
		{
			get { return minimizeFitnessValue; }
			set { minimizeFitnessValue = value; }
		}

		private object objectToCount;
		public object ObjectToCount
		{
			get { return objectToCount; }
			set { objectToCount = value; }
		}

		[XmlIgnore]
		private Vector compareVector;
		public Vector CompareVector
		{
			get { return compareVector; }
			set { compareVector = value; }
		}
	}
}
